package impl;

import anaydis.sort.SorterType;

import java.util.Comparator;
import java.util.List;

public class BubbleSorter extends AbstractSorter {
    public BubbleSorter() {
        super(SorterType.BUBBLE);
    }

    public <T> void sort(Comparator<T> comparator, List<T> list) {

        int tope = list.size();

        for (int i = 0; i < tope; i++) {
            for (int j = i + 1; j < tope; j++) {
                if (greater(comparator, list, i, j)) {
                    swap(list, i, j);
                    //PARA VER PASO A PASO LOS CAMBIOS
                    //System.out.print(" SWAP : ");
                    //System.out.println(list);
                }
                i++;
            }
            i = -1;
            tope = tope - 1;
        }
    }
}

